



//This class is used to store data in the board.
public class BoardData {
	
	//data fields
	private int[][] cells = new int[8][8];
	
	private int numWhite;
	private int numBlack;
	private int value;
	private Pair move;
	
	private int turn = BLACK;
	
	public static final int EMPTY = 0;
	public static final int WHITE = 1;
	public static final int BLACK = 2;
	
	/*return the cells with row and column*/
	public BoardData(){
		for (int col=0; col < 8; col++)
		{
			for (int row=0; row < 8; row++)
			{
				cells[row][col] = EMPTY;
	
			}
		}
		cells[3][3]=WHITE;
		cells[4][3]=BLACK;
		cells[3][4]=BLACK;
		cells[4][4]=WHITE;
		
		value = EvaluateBoard();
		move = new Pair(-1,-1);
	}
	
	public int getNumBlack(){
		return numBlack;
	}
	
	public int getNumWhite(){
		return numWhite;
	}
	
	public Pair getMove(){
		return move;
	}	
	
	public void setMove(Pair inMove){
		move = inMove;
	}
	
	public int getValue(){
		return value;
	}
	
	public void setValue(int inValue){
		value = inValue;
	}
	
	public int[][] getCells(){
		return cells;
	}
	
	public void setCell(int col, int row, int turn){
		this.cells[row][col] = turn;
	}
	
	public int getCell(int col,int row){
		return cells[row][col];
	}	
	
	public int getTurn(){
		return turn;
	}
	
	public void setTurn(int inTurn){
		turn = inTurn;
	}

	public BoardData Clone(){
		BoardData boardData = new BoardData();
		boardData.setTurn(turn);
		for(int col = 0; col < 8; col++){
			for(int row = 0; row < 8; row++){
				boardData.setCell(col, row, this.getCell(col, row));
			}
		}
		return boardData;
	}

	
	
	
	public void countPieces(){
		numWhite = 0;
		numBlack = 0;
		for(int i = 0; i < 8; i++){
			for(int j = 0; j < 8; j++){
				if(cells[i][j] == WHITE){
					numWhite++;
				}
				else if(cells[i][j] == BLACK){
					numBlack++;
				}
			}
		}
		
	}
	
	public void CheckWinner(){
		countPieces();
		System.out.println("White Player has " + numWhite + " pieces.");
		System.out.println("Black Player has " + numBlack + " pieces.");
		if(numWhite + numBlack >= 8*8){
			if(numWhite > numBlack){
				System.out.println("White Player wins!");
			}
			else if(numWhite < numBlack){
				System.out.println("Black Player wins!");
			}
			else{
				System.out.println("White and Black even.");
			}
		}
	}
	
	private int EvaluateBoard(){
		countPieces();
		value = numWhite - numBlack;
		return value;
	}
	

}

